﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ObserverPattern
{
    public abstract class TongZhiZhe
    {
        public List<DingYueZhe> dingYueZhes = new List<DingYueZhe>();
        public virtual void Add(DingYueZhe dingYueZhe)
        {
            dingYueZhes.Add(dingYueZhe);
        }
        public virtual void Remove(DingYueZhe dingYueZhe)
        {
            dingYueZhes.Remove(dingYueZhe);
        }
        public virtual void Notify()
        {
            dingYueZhes.ForEach(item =>
            {
                item.Update(name, status);
            });
        }

        private string status;
        public string Statis 
        {
            get 
            {
                return status;
            }
            set 
            {  
                status = value; 
            } 
         }
        private string name;
        public string Name
        {
            get
            {
                return name;
            }
            set
            {
                name = value;
            }
        }
    }
}
